<?php if (!defined('PmWiki')) exit();

/**

  Copyright 2011 Carlos A. Bonamigo <cabsec.pmwiki@gmail.com>

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/

/// ADDTHIS - recipe for the social bookmarking and share service at addthis.com .

$RecipeInfo['addthis']['version'] = '20110905';

SDV($AddThisAllowProfileChange , 1);
SDV($AddThisMasterProfile, '');
SDV($AddThisDefaultButton , 0);
SDV($AddThisProfile , "<script type='text/javascript'>
var addthis_config = {
     pubid: 'profile'
}
</script>
");
SDVA($AddThisButton , array(
"<a class='addthis_button' 
   href='http://www.addthis.com/bookmark.php?v=250&amp;pubid=profile'>
   <img src='http://s7.addthis.com/static/btn/sm-share-en.gif' 
      width='83' height='16' alt='Bookmark and Share' style='border:0'/>
</a>",

"<a class='addthis_button' href='http://www.addthis.com/bookmark.php?v=250&amp;pubid=profile'>
   <img src='http://s7.addthis.com/static/btn/v2/lg-share-en.gif'
      width='125' height='16' alt='Bookmark and Share' style='border:0'/>
</a>",

"<div class='addthis_toolbox addthis_default_style '>
  <a class='addthis_counter addthis_pill_style'></a>
</div>",

"<div class='addthis_toolbox addthis_default_style '>
  <a class='addthis_counter'></a>
</div>",

"<div class='addthis_toolbox addthis_default_style '>
<a href='http://www.addthis.com/bookmark.php?v=250&amp;pubid=profile'
  class='addthis_button_compact'>Share</a>
</div>",

"<div class='addthis_toolbox addthis_default_style '>
<a href='http://www.addthis.com/bookmark.php?v=250&amp;pubid=profile'
  class='addthis_button_compact'>Share</a>
<span class='addthis_separator'>|</span>
<a class='addthis_button_preferred_1'></a>
<a class='addthis_button_preferred_2'></a>
<a class='addthis_button_preferred_3'></a>
<a class='addthis_button_preferred_4'></a>
</div>",

"<div class='addthis_toolbox addthis_default_style '>
<a class='addthis_button_facebook_like' fb:like:layout='button_count'></a>
<a class='addthis_button_tweet'></a>
<a class='addthis_button_google_plusone' g:plusone:size='medium'></a>
<a class='addthis_counter addthis_pill_style'></a>
</div>",

"<div class='addthis_toolbox addthis_default_style addthis_32x32_style'>
<a class='addthis_button_preferred_1'></a>
<a class='addthis_button_preferred_2'></a>
<a class='addthis_button_preferred_3'></a>
<a class='addthis_button_preferred_4'></a>
<a class='addthis_button_compact'></a>
<a class='addthis_counter addthis_bubble_style '></a>
</div>",

"<div class='addthis_toolbox addthis_default_style '>
<a class='addthis_button_preferred_1'></a>
<a class='addthis_button_preferred_2'></a>
<a class='addthis_button_preferred_3'></a>
<a class='addthis_button_preferred_4'></a>
<a class='addthis_button_compact'></a>
<a class='addthis_counter addthis_bubble_style'></a>
</div>"

));
SDV($AddThisMenu , "<script type='text/javascript' 
  src='http://s7.addthis.com/js/250/addthis_widget.js#pubid=profile'></script>
");

markup('addthis','directives',
  '/\\(:addthis\\s(.*):\\)/ei',"AddThisWidget(PSS('$1'))");

function AddThisWidget($a){
global $AddThisProfile,$AddThisButton,$AddThisMenu,$AddThisAllowProfileChange,
   $AddThisMasterProfile,$AddThisDefaultButton,$HTMLHeaderFmt;

$args = ParseArgs($a);

if($args['button'] && 
   $args['button'] >= 0 &&
   $args['button'] <= count($AddThisButton)){
  if(is_numeric($args['button'])) $button = $args['button'];
  else $button = $AddThisDefaultButton;
}else{ $button = $AddThisDefaultButton; }

if($AddThisAllowProfileChange){
  if(!$args['profile']) $profile = $AddThisMasterProfile;
  else $profile = $args['profile'];
}else{
  $profile = $AddThisMasterProfile;
}

$AddThisProfile = str_replace("profile",$profile,$AddThisProfile);
$AddThisMenu = str_replace("profile",$profile,$AddThisMenu);

$HTMLHeaderFmt['addthis'] = "\n".$AddThisProfile.$AddThisMenu;

return Keep($AddThisButton[$button]);

}
